Add a test for invalid subcommand displayed on error.
authorKaivo Anastetiks <kaivoanastetiks@gmail.com>
Tue, 5 Jul 2016 12:09:11 +0000 (08:09 -0400)
committerKaivo Anastetiks <kaivoanastetiks@gmail.com>
Tue, 5 Jul 2016 12:09:11 +0000 (08:09 -0400)
src/bin/cargo.rs
tests/cargo.rs

index 27a349d92ae008ec875eb7190db17101b189ac3a..2c267623d2b759c5ba321e1d7ba202f0cf30ac67 100644 (file)
@@ -211,7 +211,7 @@ fn execute_subcommand(config: &Config,
             return Err(human(match find_closest(config, cmd) {
                 Some(closest) => format!("no such subcommand: `{}`\n\n\t\
                                           Did you mean `{}`?\n", cmd, closest),
-                None => "no such subcommand".to_string()
+                None => format!("no such subcommand: `{}`", cmd)
             }).into())
         }
     };
index 02900030949efdcd926958d77753c013cf4286a9..09cfa168f3da696e9c82c942b163166ebb063231 100644 (file)
@@ -105,7 +105,7 @@ fn find_closest_biuld_to_build() {
 
     assert_that(pr,
                 execs().with_status(101)
-                       .with_stderr("[ERROR] no such subcommand
+                       .with_stderr("[ERROR] no such subcommand: `biuld`
 
 <tab>Did you mean `build`?
 
@@ -121,7 +121,18 @@ fn find_closest_dont_correct_nonsense() {
 
     assert_that(pr,
                 execs().with_status(101)
-                       .with_stderr("[ERROR] no such subcommand
+                       .with_stderr("[ERROR] no such subcommand: `there-is-no-way-that-there-is-a-command-close-to-this`
+"));
+}
+
+#[test]
+fn displays_subcommand_on_error() {
+    let mut pr = cargo_process();
+    pr.arg("invalid-command");
+
+    assert_that(pr,
+                execs().with_status(101)
+                       .with_stderr("[ERROR] no such subcommand: `invalid-command`
 "));
 }